<template>
  <el-upload class="upload-demo" :action="'http://124.70.196.178:8080/intelligent_control_webservice_eeds/' + url" :show-file-list="false" :headers="headers" name="fileName" :data="data" list-type="text" :on-success="upSuccess">
    <el-button>导入</el-button>
  </el-upload>
</template>
<script>
export default {
  name: 'FileUpload',
  props: {
    url: { type: String, default: '' },
    examinationRoomId: { default: '' }
  },
  computed: {
    headers() {
      return {
        Authorization: window.localStorage.getItem('token')
      }
    },
    data() {
      return {
        idDto: this.examinationRoomId
      }
    }
  },
  methods: {
    upSuccess(res) {
      if (res.code == 200) {
        this.$message({
          showClose: true,
          message: res.msg,
          type: 'success'
        })
        this.$emit('onSubmit')
      } else {
        this.$message({
          showClose: true,
          message: res.msg,
          type: 'error'
        })
      }
    }
  }
}
</script>
<style lang="less" scoped>
.upload-demo {
  margin-left: 10px;
  margin-right: 10px;
  width: 70px;
  height: 40px;
}
</style>